//
//  QZMyTitleCell.m
//  shortvideoplay
//
//  Created by adam on 2024/9/22.
//

#import "QZMyTitleCell.h"
#import "QZMyTitleCellModel.h"

@implementation QZMyTitleCell
- (void)initializeViews {
    [super initializeViews];
    self.suoImageView = [[UIImageView alloc] init];
    self.suoImageView.userInteractionEnabled = YES;
    self.suoImageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.suoImageView];
    
   
    
    KWeakSelf
    [self.suoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(13));
        make.centerY.equalTo(weakSelf);
        make.right.equalTo(weakSelf.titleLabel.mas_left).offset(-2);
    }];
}
- (void)reloadData:(JXCategoryBaseCellModel *)cellModel {
    [super reloadData:cellModel];
    if ([cellModel isKindOfClass:[QZMyTitleCellModel class]]) {
        QZMyTitleCellModel *model = (QZMyTitleCellModel *)cellModel;
        if(model.isSelected){
            self.suoImageView.image = KImageNamed(model.imgName_sel);
        }else{
            self.suoImageView.image = KImageNamed(model.imgName_nor);
        }
        
        self.suoImageView.hidden = YES;
        self.suoImageView.hidden = model.hiddeImg;
    }
}


- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *view = [super hitTest:point withEvent:event];
    if (view == nil) {
        //将坐标由当前视图发送到 指定视图 fromView是无法响应的范围小父视图
        if (self.suoImageView != nil && !self.suoImageView.isHidden) {
            CGPoint stationPoint = [self.suoImageView convertPoint:point fromView:self];
            if (CGRectContainsPoint(self.suoImageView.bounds, stationPoint))
            {
                view = self.suoImageView;
            }
        }
    }
    return view;
}
@end
